﻿CREATE FUNCTION [dbo].[fn_FunctionExists]
(
	@Function sysname
)
RETURNS BIT
AS
BEGIN
	DECLARE @True  BIT; SET @True  = 1
	DECLARE @False BIT; SET @False = 0

	IF EXISTS (
		   SELECT *
		   FROM   sys.objects o
		   WHERE  o.[type] IN ('IF', 'TF', 'FN')
				  AND o.[name] = @Function
	   )
		RETURN @True

	RETURN @False
END